<template>
	<div class="tabs2">
		<!-- 搜素框 -->
		<div class="box1">
			<button class="select">查询内容</button>
			<input type="text" placeholder="请输入要搜索的的内容..."/>
			<ul class="ulbut">
				<!-- 全部商品 -->
				<li><p><button @click="btn(0)">全部商品</button><span>></span></p></li>
				<!-- 循环出对应的商品数据 -->
				<li v-for="item in tab2List" :key="item.id">
						<p><button @click="btn(item.id)">{{item.type}}</button><span>></span></p>
				</li>
			</ul>
		</div>
		<div class="box2">
			<ul>
				<!-- 获取对应的商品数据 -->
				<li v-for="item in arr" :key="item.id">
					<img :src="`${$Imgurl}/api/public/showImg/${item.picture}`" />
					<div class="boxp">
						<p>{{item.name}}</p>
						<p>{{item.author}}</p>
						<p>{{item.publisher}}</p>
						<p>￥{{item.price}}<button>购买</button></p>
					</div>
				</li>
			</ul>
		</div>
	</div>
</template>

<script>
	export default{
		name:'Tabs2',
		data(){
			return{
				tab2List:[],//接收左边数据
				arr:[],	//接收右边数据
			}
		},
		methods:{
			//获取对应的数据
			btn(x){
				//发起异步请求 接收右边数据
				this.axios.get('/api/public/findBookByPage/0/12/'+x).then((res)=>{
					if(res.status === 200){
							this.arr = res.data.data.books
					}
				}).catch((error)=>{
					console.log(error)
				})
			}
		},
		created() {
			//发起异步请求 接收左边数据
			this.axios.get('/api/public/type/findAll').then((res)=>{
				if(res.status === 200){
					this.tab2List = res.data.data
				}
			}).catch((error)=>{
				console.log(error)
			})

		}
	}
</script>

<style scoped>
.tabs2 button{
	cursor: pointer;
}
.tabs2{
	height: 800px;
	margin: 30px auto;
	background-color: aquamarine;
	width: 95%;
	border-radius: 15px;
	padding-bottom: 10px;
}
.boxp p:nth-child(4){
	color:white;
	font-weight: bold;
}
.box2{
	float: right;
	width: 75%;
}
.box2 ul li{
	float: left;
}
.boxp{
	margin-top: 20px;
	margin-left: 20px;
	width: 150px;
	float: right;
}
.boxp p{
	padding-top: 10px;
}
.boxp button{
	margin-left: 10px;
	border: none;
	background-color: white;
	color: black;
	width: 50px;
	border-radius: 2px;
	padding: 4px;
}
.boxp button:hover{
	color: black;
}
.box2 img{
	margin-top: 20px;
	margin-left: 50px;
	height: 150px;
	width: 150px;
	padding-left: 30px;
}
.box1{
	float: left;
	width: 22%;
}
.select{
	width: 80px;
	margin: 15px;
	border: none;
	background-color: white;
	border-radius: 10px;
	line-height: 30px;
	font-size: 15px;
	color: black;
	font-weight: bold;
}
.box1 ul li span{
	float: right;
	color: black;
}
.box1 ul li p{
	padding-left: 20px;
}
.box1 ul li p button:hover{
	color: black;
}
.box1 ul li{
	line-height: 50px;
}
.box1 ul li:nth-child(1) p{
	padding-bottom: 10px;
	border-bottom: 2px solid white;
}
.box1 p button{
	padding-right: 100px;
	border: none;
	background-color: white;
	color: black;
	font-size: 15px;
}
.box1 input{
	width: 180px;
	line-height: 30px;
	border: none;
	text-indent: 0.5em;
}
</style>
